package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SwapFaceBatch;
import com.ruoyi.system.service.ISwapFaceBatchService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 批次换脸Controller
 * 
 * @author ruoyi
 * @date 2024-09-27
 */
@RestController
@RequestMapping("/system/batch")
public class SwapFaceBatchController extends BaseController
{
    @Autowired
    private ISwapFaceBatchService swapFaceBatchService;

    /**
     * 查询批次换脸列表
     */
    @PreAuthorize("@ss.hasPermi('system:batch:list')")
    @GetMapping("/list")
    public TableDataInfo list(SwapFaceBatch swapFaceBatch)
    {
        startPage();
        List<SwapFaceBatch> list = swapFaceBatchService.selectSwapFaceBatchList(swapFaceBatch);
        return getDataTable(list);
    }

    /**
     * 导出批次换脸列表
     */
    @PreAuthorize("@ss.hasPermi('system:batch:export')")
    @Log(title = "批次换脸", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SwapFaceBatch swapFaceBatch)
    {
        List<SwapFaceBatch> list = swapFaceBatchService.selectSwapFaceBatchList(swapFaceBatch);
        ExcelUtil<SwapFaceBatch> util = new ExcelUtil<SwapFaceBatch>(SwapFaceBatch.class);
        util.exportExcel(response, list, "批次换脸数据");
    }

    /**
     * 获取批次换脸详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:batch:query')")
    @GetMapping(value = "/{batchId}")
    public AjaxResult getInfo(@PathVariable("batchId") Long batchId)
    {
        return success(swapFaceBatchService.selectSwapFaceBatchByBatchId(batchId));
    }

    /**
     * 新增批次换脸
     */
    @PreAuthorize("@ss.hasPermi('system:batch:add')")
    @Log(title = "批次换脸", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SwapFaceBatch swapFaceBatch)
    {
        return toAjax(swapFaceBatchService.insertSwapFaceBatch(swapFaceBatch));
    }

    /**
     * 修改批次换脸
     */
    @PreAuthorize("@ss.hasPermi('system:batch:edit')")
    @Log(title = "批次换脸", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SwapFaceBatch swapFaceBatch)
    {
        return toAjax(swapFaceBatchService.updateSwapFaceBatch(swapFaceBatch));
    }

    /**
     * 删除批次换脸
     */
    @PreAuthorize("@ss.hasPermi('system:batch:remove')")
    @Log(title = "批次换脸", businessType = BusinessType.DELETE)
	@DeleteMapping("/{batchIds}")
    public AjaxResult remove(@PathVariable Long[] batchIds)
    {
        return toAjax(swapFaceBatchService.deleteSwapFaceBatchByBatchIds(batchIds));
    }
}
